package com.parenting.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;

import com.parenting.request.ShopperChildCheckDTO;
import com.parenting.response.ShopperCheckVO;
import com.parenting.sevice.ShopperFetationService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 孕妇认证照片 前端控制器
 * </p>
 *
 * @author zcj
 * @since 2021-05-12
 */
@RestController
@RequestMapping("/plaza/shopperFetation")
@Api(tags = "孕妇认证审核")
public class ShopperFetationController {

    @Autowired
    private ShopperFetationService shopperFetationService;



    @ApiOperation(value = "孕妇审核列表", httpMethod = "GET")
    @GetMapping("/checkFetationList/{current}/{size}/{type}")
    public Result<Page<ShopperCheckVO>> checkFetationList(@ApiParam(name = "current", value = "页码", required = true)
                                                            @PathVariable("current") @NotNull(message = "页码不能为空") Integer current,
                                                          @ApiParam(name = "size", value = "每页显示多少条", required = true)
                                                            @PathVariable("size") @NotNull(message = "每页显示多少条不能为空") Integer size,
                                                          @ApiParam(name = "type", value = "搜索类型1:全部2:待审核3:已审批4:已拒绝", required = true)
                                                            @PathVariable("type") @NotNull(message = "每页显示多少条不能为空") Integer type) {
        return shopperFetationService.checkFetationList(current, size, type);
    }

    @ApiOperation(value = "审核孕妇认证", httpMethod = "PUT")
    @PutMapping("/check/{id}")
    public Result check(@RequestBody @Validated ShopperChildCheckDTO ShopperDTO,
                          @ApiParam(name = "id", value = "id", required = true)
                          @PathVariable("id") @NotNull(message = "id不能为空") Integer id) throws JsonProcessingException {
        return shopperFetationService.check(ShopperDTO, id);
    }

}

